<!DOCTYPE HTML>
<html>

<head>
  <meta charset="utf-8">
  <title></title>

  <script type="text/javascript">
  //   ws=null
  //  function init(){
  //   //let addr="ws://192.168.0.105:8088/test/web/dasf"
  //   let addr="ws://39.106.224.223:8088/chat/socket/test@qq.com/test";
  //   ws=new WebSocket(addr);
  //   ws.onmessage=function(data)
  //   {
  //    console.log("message:"+data.data);
  //   }
  //   ws.onopen=function(){
  //    console.log("open init");
  //   }

  //  }
  //  init()
    function WebSocketTest() {
        // 打开一个 web socket
        var ws = new WebSocket("wss://www.slowcommunity.top/chat/socket/lh123/lh123");
        console.log(ws);
        ws.onopen = function () {
          var message = {
            deleverType: 0X10,
            fromAccount:'lh123',
            messageType: 0X01,
            msg:'你好！！',
            toAccount:'li0117'
          }; //json格式要发送的消息

          // Web Socket 已连接上，使用 send() 方法发送数据
          ws.send(JSON.stringify(message));
          alert("数据发送中...");
        };
        ws.onmessage = function (evt) {
          var received_msg = JSON.parse(evt.data);
          console.log(received_msg);
          alert("数据已接收...");
        };
    }
    WebSocketTest()

    // function WebSocketTest1() {
    //     // 打开一个 web socket
    //     var ws = new WebSocket("ws://39.106.224.223:8088/chat/socket/li0117/li0117");
    //     ws.onmessage = function (evt) {
    //       var received_msg = JSON.parse(evt.data);
    //       console.log(received_msg);
    //       alert("数据已接收...");
    //     };
    // }
    // WebSocketTest1()

   
  </script>

</head>

<body>

  <div id="sse">
    
  </div>

</body>

</html>